//
//  ZHVisitTableViewController.swift
//  weibosina
//
//  Created by zhangzhen on 16/6/3.
//  Copyright © 2016年 zhangzhen. All rights reserved.
//

import UIKit

class ZHVisitTableViewController: UITableViewController,VisitorButtonDelegate {
    //设置用户登录的标记,可以通过access_token来判断
    private var userLogin = ZHUserAccountViewModel.shareUserAccount.userLogin
//    private var userLogin = false
    //创建一个变量view
    var visitorView = VisitorView()
    
    
    
    //实现代理方法
    func visitorRegisterButtonDid() {
        print("用户点击注册按钮")
        
    }
    
    
    func visitorLoginButtonDid() {
        print("用户点击了登录按钮")
        
        //跳转到登录界面
        let loginVc = ZHLoginViewController()
        let nav = UINavigationController(rootViewController: loginVc)
        nav.view.backgroundColor = UIColor.whiteColor()
        
        presentViewController(nav, animated: true, completion: nil)
        
    }
    
    

    
    
    override func loadView() {
        //根据用户的登录标记来显示view
//        visitorView.backgroundColor = UIColor.darkGrayColor()
        
        //设置代理
        visitorView.delegate = self
        
        userLogin ? super.loadView() : (view = visitorView)
    }
    
    
    override func viewDidLoad() {
        
        super.viewDidLoad()
        
        //创建BarButtonItem
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "visitorRegisterButtonDid")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "visitorLoginButtonDid")
    }
    
   

   
}

  